package com.groupseven.happycampus.common.instener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.groupseven.happycampus.common.bo.ParttimeDayBo;
import com.groupseven.happycampus.common.pojo.ParttimeDay;
import com.groupseven.happycampus.service.ParttimeDayService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 * @CreateTime: 2022-07-26  20:26
 */
@Component
@Scope("prototype")
public class WebParttimeDayListener extends AnalysisEventListener<ParttimeDayBo> {

    @Autowired
    ParttimeDayService parttimeDayService;

    @Override
    public void invoke(ParttimeDayBo parttimeDayBo, AnalysisContext analysisContext) {
        System.out.println(parttimeDayBo);
        ParttimeDay parttimeDay = new ParttimeDay();
        BeanUtils.copyProperties(parttimeDayBo, parttimeDay);
        parttimeDayService.insertParttimeDay(parttimeDay);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
